import {createAsyncThunk, createSlice} from "@reduxjs/toolkit";
import {reqGetComment} from "../../api/frontDesk/frontDeskApi";

export const getCommentList = createAsyncThunk(
    'comment/getCommentListStatus',
    async (id) => {
        const data = await reqGetComment(id)
        console.log(data)
        const {comments} = data
        return comments
    }
)

const commentSlice = createSlice({
    name: 'comment',
    initialState: {
        commentList: []
    },
    reducers: {},
    extraReducers: (builder) => {
        builder.addCase(getCommentList.fulfilled, (state, {payload}) => {
            state.commentList = payload
        })
    }
})

export const {reducer: commentReducer} = commentSlice